#include "ams_core.h"
// 判断任务是否到时
bool Task::onTime(const DayTimePoint &dtp) {
    return t.h == dtp.h && t.m == dtp.m && t.s == dtp.s;
}
// 执行任务
int Task::exec() {
    return system(src.c_str());
}
// 读取任务列表
void readTasks(vector<Task> &ts) {
    ifstream in("tasks.ini");
    int h, m, s;
    string src;
    if (!in.is_open()) {
        errorResult("Missing task.ini!");
        exit(0);
    }
    while (!in.eof()) {
        in >> h >> m >> s >> src;
        DayTimePoint d(h, m, s);
        Task t(d, src);
        ts.push_back(std::move(t));
    }
}
// 用windows api 获取当前时间
DayTimePoint TimeHelper::getCurrentDayTimePoint() {
    SYSTEMTIME sys;
    GetLocalTime(&sys);
    return std::move(DayTimePoint(sys.wHour, sys.wMinute, sys.wSecond));
}